const weekday_cn = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
const weekday_en = ['Sun', 'Mon', 'Tues', 'Wed', 'Thur', 'Fri', 'Sat'];
const month_en = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul','Aug','Sep','Oct','Nov','Dec'];
export const formatDateTimeUs = (date:any = null) => {
    if(!date){
        date = new Date();
    }
    return `${weekday_en[date.getDay()]}, ${date.getDate().toString().padStart(2,'0')} ${month_en[date.getMonth()]} ${date.getFullYear()} ${date.getHours().toString().padStart(2,'0')}:${date.getMinutes().toString().padStart(2,'0')}:${date.getSeconds().toString().padStart(2,'0')} GMT`
}

export const base64_encode = (str) => { 
    var c1, c2, c3; 
    var base64EncodeChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; 
    var i = 0, len= str.length, string = ''; 
    while (i < len){ 
        c1 = str.charCodeAt(i++) & 0xff; 
        if (i == len){ 
            string += base64EncodeChars.charAt(c1 >> 2); 
            string += base64EncodeChars.charAt((c1 & 0x3) << 4); 
            string += "=="; 
            break; 
        } 
        c2 = str.charCodeAt(i++); 
        if (i == len){ 
            string += base64EncodeChars.charAt(c1 >> 2);
            string += base64EncodeChars.charAt(((c1 & 0x3) << 4) | ((c2 & 0xF0) >> 4)); 
            string += base64EncodeChars.charAt((c2 & 0xF) << 2); string += "="; 
            break; 
        } 
        c3 = str.charCodeAt(i++); 
        string += base64EncodeChars.charAt(c1 >> 2); 
        string += base64EncodeChars.charAt(((c1 & 0x3) << 4) | ((c2 & 0xF0) >> 4)); 
        string += base64EncodeChars.charAt(((c2 & 0xF) << 2) | ((c3 & 0xC0) >> 6)); 
        string += base64EncodeChars.charAt(c3 & 0x3F) 
    } 
    return string 
}